

struct Counter {
    current : i64
}

impl Counter {
    fn new() -> Self{
        Counter{
            current: 0
        }
    }
    fn next(&mut self) -> i64 {
        let c = self.current;
        self.current = c + 1;
        c
    }

/*    fn current(&self) -> i64 {
        self.current
    }*/
}





/*
struct Round {
}*/

struct Game {
    name : String,
    round_counter: Counter,
}


impl Game {
    fn new() -> Self{
        Game {
            name: "exchange".to_string(),
            round_counter : Counter::new()
        }
    }
    fn new_round(&mut self){
        self.rounds.append(Round::new(self.round_counter.next()))
    }
}





trait Resource {
    fn prepare(&mut self);
    fn run(&mut self);
    fn end(&mut self);
}

impl Resource for Game {
    fn prepare(&mut self) {
        //Round::new(round_counter.next());
        println!("game prepare {0} {1}", self.name, self.round_counter.next())
        //self.select_master_player(player1)
        //self.select_second_player(player2)
    }
    fn run(&mut self) {
        println!("game start run");
        
        loop {
            //1. next_round();
            let mut round = self.new_round();
            round.prepare();
            round.run();
            round.end();
            break;
        }
    }
    fn end(&mut self){
        println!("game end");
    }
}


#[cfg(test)]
mod test {
    use super::*;

    #[test]
    fn interface(){
        let mut res = Game::new();
        res.prepare();
        res.run();
        res.end();
    }
}

